package com.beaven.imclient.presenter.chat;

import com.beaven.model.data.DataSource;
import com.beaven.model.data.message.SessionRepository;
import com.beaven.model.model.db.Session;
import java.util.List;

/**
 * author: Beaven
 * time: 2017/6/1 15:36
 */

public class SessionPresenter
    implements SessionContract.Presenter, DataSource.SuccessCallBack<List<Session>> {

  private SessionContract.View view;
  private SessionRepository repository;

  public SessionPresenter(SessionContract.View view) {
    this.view = view;
    repository = new SessionRepository();
  }

  @Override public void subscribe() {
    repository.load(this);
  }

  @Override public void unSubscribe() {
    repository.dispose();
  }

  @Override public void notifyData() {
    repository.load(this);
  }

  @Override public void loadDataSuccess(List<Session> sessionList) {
    view.showList(sessionList);
  }
}
